﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IHISCETeim.DAL;
using IHISCETeim.Model;
using IHISCETeim.Library;
using System.Data;


namespace IHISCETeim.BLL
{
    public class JSDWFApplyController
    {
        /// <summary>
        /// 添加图纸申请
        /// </summary>
        /// <param name="ApplyUserName"></param>
        /// <param name="Remark"></param>
        /// <param name="DWFIDS"></param>
        /// <returns></returns>
        public static int Add(string ApplyUserName, int AdtlvlID,  string Remark, string DWFIDS)
        {
            return JSDWFApplyDAL.Add(ApplyUserName,AdtlvlID, Remark, DWFIDS);
        }
        /// <summary>
        /// 审批完成,通过
        /// </summary>
        /// <param name="ApplyGUID"></param>
        public static void CompleteFlowPass(Guid ApplyGUID)
        {
             JSDWFApplyDAL.CompleteFlowPass(ApplyGUID);
        }
        /// <summary>
        /// 审批完成,拒绝
        /// </summary>
        /// <param name="ApplyGUID"></param>
        /// <param name="Remark"></param>
        public static void CompleteFlowReject(Guid ApplyGUID, string Remark)
        {
            JSDWFApplyDAL.CompleteFlowReject(ApplyGUID, Remark);
        }
        /// <summary>
        /// 获取审批信息项
        /// </summary>
        /// <param name="ApplyGUID"></param>
        /// <returns></returns>
        public static JSDWFApplyInfo  GetByApplyGUID(Guid ApplyGUID)
        {
            return CBO.FillObject<JSDWFApplyInfo>(JSDWFApplyDAL.GetByApplyGUID(ApplyGUID));
        }
        /// <summary>
        /// 获取相应审批明细
        /// </summary>
        /// <param name="ApplyGUID"></param>
        /// <returns></returns>
        public static DataTable GetDetailByApplyGUID(Guid ApplyGUID)
        {
            return JSDWFApplyDAL.GetDetailByApplyGUID(ApplyGUID);
        }

        /// <summary>
        /// 根据用户名查看此用户目前正在审请的图纸
        /// </summary>
        /// <param name="ApplyGUID"></param>
        /// <returns></returns>
        public static List<JSDWFApplyDetailInfo> GetDWFApplyByUserName(string UserName)
        {
            return CBO.FillCollection<JSDWFApplyDetailInfo>(JSDWFApplyDAL.GetDWFApplyByUserName(UserName));
        }

        /// <summary>
        /// 获取需发送的邮件 的申批 JSDWFApply
        /// </summary>
        /// <returns></returns>
        public static List<JSDWFApplyInfo> GetNeedSendEmail()
        {
            return CBO.FillCollection<JSDWFApplyInfo>(JSDWFApplyDAL.GetNeedSendEmail());
        }
        /// <summary>
        /// 进入下一个审批流程
        /// </summary>
        /// <param name="ApplyGUID"></param>
        /// <param name="NextFlowID"></param>
        /// <returns></returns>
        public static bool UpdateNextFlow(Guid ApplyGUID, int NextFlowID)
        {
            return JSDWFApplyDAL.UpdateNextFlow(ApplyGUID, NextFlowID);
        }
        /// <summary>
        /// 更新邮件状态为已发送
        /// </summary>
        /// <param name="ApplyGUID"></param>
        /// <returns></returns>
        public static bool UpdateSendEmailState(Guid ApplyGUID)
        {
            return JSDWFApplyDAL.UpdateSendEmailState(ApplyGUID);
        }
        /// <summary>
        /// 获取申请历史列表
        /// </summary>
        /// <param name="WhereSql"></param>
        /// <param name="PageIndex"></param>
        /// <param name="PageSize"></param>
        /// <param name="Sort"></param>
        /// <param name="TotalCount"></param>
        /// <returns></returns>
        public static DataTable GetPagination(string WhereSql, int PageIndex, int PageSize, string Sort, ref int TotalCount)
        {
            return JSDWFApplyDAL.GetPagination(WhereSql, PageIndex, PageSize, Sort, ref  TotalCount);
        }
    }
}
